package models;

import java.sql.Date;

import java.util.*;

import javax.persistence.*;

import play.db.ebean.*;
import play.data.format.*;
import play.data.format.Formats.DateTime;
import play.data.validation.*;
import play.data.validation.Constraints.Required;

import play.db.ebean.Model;

@Entity
public class TimeLog extends Model {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1992626159123806006L;

	@Id
	public Long id;

	@Required
	public String name;

	public String startWorkTime;

	public String endWorkTime;

	public String startBreakTime;

	public String endBreakTime;

	public String startOtTime;

	public String endOtTime;

	public Integer PTO;

	public String date;

	public static Finder<Long, TimeLog> find = new Finder<Long, TimeLog>(
			Long.class, TimeLog.class);

	public static TimeLog findByName(String name) {
		return find.where().eq("name", name).findUnique();
	}
	
	public static List<TimeLog> findAll(){
		return find.findList();
	}
	
	public static List<TimeLog> findAllByName(String name){
		return find.where().eq("name", name).findList();
	}

	public static void create(TimeLog developer) {
		developer.save();
	}
	
	public void update(TimeLog developer) {
		developer.update(developer);
	}

	public static TimeLog findByDate(String date) {
		return find.where().contains("startWorkTime", date).findUnique();
	}

	public void delete(Long id2) {
		find.ref(id2).delete();
		
	}

	public static void remove(Long id2) {
		find.ref(id2).delete();
	}


}
